import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router);

export const constantRoutes = [
    {
        path: '/login',
        component: () => import('@/views/login/Login'),
        hidden: true
    },
    {
        path: '/index',
        component: () => import('@/views/Index'),
        // home页面并不需要被访问
        redirect: '/home',
        children: [
            {
                path: '/home', // 首页
                component: () => import('@/views/home/HomeIndex'),
                hidden: true,
                meta: {
                    requireAuth: true
                }
            },
            {
                path: '/note', // 笔记本
                component: () => import('@/views/note/NoteIndex'),
                hidden: true,
                meta: {
                    requireAuth: true
                }
            },
            {
                path: '/library', // 图书馆
                component: () => import('@/views/library/LibraryIndex'),
                hidden: true,
                meta: {
                    requireAuth: true
                }
            },
            {
                path: '/personal', // 个人中心
                component: () => import('@/views/personal/PersonalIndex'),
                children: [
                    {
                        path: 'index',
                        component: () => import('@/views/personal/SystemIndex'),
                        name: "SystemIndex",
                        meta: { title: "系统首页" },
                    },
                    {
                        path: 'book',
                        component: () => import('@/views/personal/SystemBook'),
                        name: "SystemBook",
                        meta: { title: "图书管理" },
                    },
                    {
                        path: 'note',
                        component: () => import('@/views/personal/SystemNote'),
                        name: "SystemNote",
                        meta: { title: "文章管理" },
                    },
                    {
                        path: 'system/user',
                        component: () => import('@/views/personal/SystemUser'),
                        name: "SystemUser",
                        meta: { title: "用户管理" },
                    },
                    {
                        path: 'system/log',
                        component: () => import('@/views/personal/SystemLog'),
                        name: "SystemLog",
                        meta: { title: "日志管理" },
                    }
                ]
            }
        ]
    }
];

export default new Router({
    mode: 'history', // 去掉url中的#
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
})
